/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;
import java.util.Comparator;

/**
 * <p>Project: javase - Arr7
 * <p>Powered by webrx On 2021-11-26 15:54:29
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Arr7 {
    public static void main(String[] args) {
        String[] ss = new String[]{"an", "javascript", "egg", "book", "user", "zoo", "c", "c++"};
        System.out.println(Arrays.toString(ss));

        //字母升序
        Arrays.sort(ss);

        System.out.println(Arrays.toString(ss));

        //字母降序
        Arrays.sort(ss, Comparator.reverseOrder());

        System.out.println(Arrays.toString(ss));

        //按字母个数排序
        Arrays.sort(ss, Comparator.comparingInt(String::length));

        System.out.println(Arrays.toString(ss));
    }
}
